home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / Chip Temmuz 2004.iso / program / antispam / RazorAgent_SDK / razor-agents-sdk-2.03.exe / Digest-Nilsimsa-0.06 / t / 00_load.t next >
Encoding:
Text File  |  2002-05-21  |  1.6 KB  |  50 lines

  1. # this can also be run from parent dir by
  2. # perl -Iblib/lib -Iblib/arch/auto/Digest/Nilsimsa t/00_load.t
  3.  
  4. BEGIN { $| = 1; print "1..7\n"; }
  5. END {print "not ok 1\n" unless $loaded;}
  6. use Digest::Nilsimsa;
  7. $loaded = 1;
  8. print "ok 1\n";
  9.  
  10. my $n = new Digest::Nilsimsa;
  11. print $n->testxs('iamchad') eq 'amchad' ? "" : "not ", "ok 2\n";
  12.  
  13. my $text = "chad #1";
  14. my $digest = $n->text2digest($text);
  15. #print STDERR "\ndigest('". $text ."'): $digest\n";
  16. print "not " unless (defined($digest) && $digest eq "0120010810080004004122001200a8000a000020810000000000c00310400000");
  17. print "ok 3\n";
  18.  
  19. # tests 4..7 are read from files
  20. # if filename does not have absolute path, relative to the t/ directory
  21. #
  22. # NOTE: if different files have same key, only one will be in hash table
  23. #
  24. my %files = qw(
  25. 3c000981d4c41101baca8811b1b212031504b0819488a30402d02a201c72a408 a.txt
  26. 7fb4e5880370384c220298c94f844b35058e3c734920454765508bb57630e3ee b.txt
  27. 7fb0e5a89251884cb15218b19f841731448f7d33593046442f308b10f630716e d.txt
  28. 340e20024f758264538a09024200d8a24004940439015a1a04500a2042a24120 chad.jpg
  29. );
  30. my $skip = "
  31. ";
  32.  
  33. my $ok=4;
  34. foreach (sort {$files{$a} cmp $files{$b}} keys %files) {
  35.   my $fn = $files{$_};
  36.   $fn = "t/$fn" unless ($fn =~ /^\//);
  37.   open(INF,$fn) or die "\ncan't find $fn\n";
  38.   my $text = join '', <INF>;
  39.   close INF;
  40.     $digest = $n->text2digest($text);
  41. #print STDERR "\ndigest($fn): $digest\n";
  42. #print STDERR "\ndigest($fn) errmsg: ". $n->errmsg() ."\n";
  43. #  print "$fn \t\t";
  44.   print "not " unless (defined($digest) && $digest eq $_);
  45.   print "ok $ok $fn\n";
  46.   $ok++;
  47. }
  48.  
  49. print "Done.\n\n";
  50.